import requests
from bs4 import BeautifulSoup

def fetch_blog_data(url):
    try:
        # 发送HTTP请求获取网页内容
        response = requests.get(url)
        response.raise_for_status()  # 如果请求不成功，会抛出异常

        # 使用Beautiful Soup解析网页内容
        soup = BeautifulSoup(response.content, 'html.parser')

        # 定位文章列表，根据实际网页结构修改选择器
        articles = soup.select('div.article')  # 使用合适的CSS选择器定位文章列表

        # 遍历提取的文章列表
        for article in articles:
            title = article.select_one('h2.title').text.strip()  # 文章标题
            content = article.select_one('div.content').text.strip()  # 文章内容
            print(f"Title: {title}")
            print(f"Content: {content}")
            print("--------------")

    except requests.exceptions.RequestException as e:
        print(f"Failed to retrieve content from {url}")
        print(e)

# 示例调用
url = 'https://example.com/special-column'  # 替换为目标专栏的URL
fetch_blog_data(url)
